#!/bin/sh

# $1 : type de l'instance, exemple : ami-baba68d3


export EC2_PRIVATE_KEY=pk-OYYLKCVZFZW3LQTNV7KSPOYAHMXRTA2K.pem
export EC2_CERT=cert-OYYLKCVZFZW3LQTNV7KSPOYAHMXRTA2K.pem

run=$(ec2-run-instances $1 -t t1.micro -k pstam-keypair | grep INSTANCE | cut -d$'\t' -f2)
url=$(ec2-describe-instances | grep "INSTANCE" | grep "$run" | cut -d$'\t' -f4 | sed -e "s/[\t]/ /g")


#sleep 60
#scp  -o "StrictHostKeyChecking no" -i id_rsa-pstam-keypair -p test.sh  ec2-user@$url:.
#ssh  -o "StrictHostKeyChecking no" -i id_rsa-pstam-keypair ec2-user@$url 'chmod u+x test.sh ; sh ./test.sh'

echo $url

